
public class Main {
    public static void test(animal animal){
        animal.eat();
    }
    public static void test1(Running run){
        run.run();
    }
    public static void test2(Swimming swim){
        swim.swim();
    }
    public static void test3(flying fly){
        fly.fly();
    }

    public static void main(String[] args) {
        Bird bird = new Bird("小鸟",12);
        Frog frog = new Frog("青蛙",1);
        //eat是父类的函数，此处是多态的实现
        test(bird);
        test(frog);

        //鸟不会游泳，所以无法调用鸟来执行test2
        //test2(bird);
        test2(frog);

        //同理，青蛙不会飞
        test3(bird);
        //test3(frog);
    }
}